import 'package:flutter/material.dart';
import 'package:jd_flutter/base/foundation/flutter_extension.dart';
import 'package:jd_flutter/base/foundation/jd_device.dart';
import 'package:jd_flutter/base/widget/image/jd_network_image.dart';

class HomeBottomWidget extends StatelessWidget {
  final List<String> urlList;
  final String? count;

  const HomeBottomWidget({super.key, required this.urlList, this.count});

  @override
  Widget build(BuildContext context) {
    List<String> currentUrlList = urlList.take(3).toList();
    int currentCount = currentUrlList.length;
    List<Widget> widgetList = [];
    currentUrlList.reversed.toList().mapIndex((index, element) {
      widgetList.add(Positioned(
        left: (currentCount - index - 1) * 12,
        top: 0,
        child: JDNetworkImage(
          url: element,
          size: const Size(16, 16),
          borderColor: Colors.yellow,
          borderWidth: 2,
          borderRadius: const BorderRadius.all(Radius.circular(8)),
        ),
      ));
    });

    return SizedBox(
      width: JDDevice.width - 36,
      height: 16,
      child: Stack(
        children: [
          ...widgetList,
          Positioned(
              left: 12 * widgetList.length + 4,
              child: Text(
                overflow: TextOverflow.ellipsis,
                '${count.notNull}人浏览',
                style: const TextStyle(color: Color(0xFF999999), fontSize: 13),
              ))
        ],
      ),
    );
  }
}
